package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.pojo.Order;
import com.itheima.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 32338
 * @date 2024-05-04 14:43:26
 * @description 预约管理
 */
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * @description
     ***:分页查询
     **/
    @PostMapping("/findPage")
    public PageResult page(@RequestBody QueryPageBean queryPageBean){
        log.info("分页查询预约管理：{}",queryPageBean);

        PageResult pageResult = orderService.page(queryPageBean);

        return pageResult;
    }


    /**
     * @description
     ***:预约状态管理
     **/
    @PostMapping("/update")
    public Result update(@RequestBody Order order){
        log.info("修改预约状态：{}",order);

        orderService.update(order);

        return new Result(true, MessageConstant.ORDERSETTING_SUCCESS);
    }

    /**
     * @description
     ***:根据预约id查询回显
     **/
    @GetMapping("/findById")
    public Result findById(Integer id){
        log.info("根据预约id查询回显:{}",id);

        Order order = orderService.findById(id);

        return new Result(true,MessageConstant.QUERY_ORDER_SUCCESS,order);
    }



}
